package com.ymatou.iapi.prod.testcase;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.prod.parameter.IsFavoriteBean;
import com.ymatou.iapi.prod.service.IsFavoriteCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.tag.P1;
import com.ymttest.business.service.SellerProductCallService;
import com.ymttest.utils.EnvSetup;

public class Ts_IsFavorite {
	
	private static IsFavoriteBean isFavoriteBean;
	private static IsFavoriteCall isFavoriteCall;
	
	private static int sellerId = Integer.parseInt(EnvSetup.getData("zhangyi_seller002_id"));
	private static String sellerName = EnvSetup.getData("zhangyi_seller002_name");

	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("获取商品是否收藏");
	}

	@Before
	public void caseUp() throws Exception {
		isFavoriteBean = new IsFavoriteBean();
		isFavoriteCall = new IsFavoriteCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(isFavoriteCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Ts_GetProductInfo_001() {
		 Logger.start(true,"商品是否收藏接口数据验证");
		 try {
			 String productId = SellerProductCallService.addNewProductOnSale(sellerId, 
					 sellerName, null).getJSONObject("Data").getString("ProductID");
			 
			 isFavoriteBean.setProductId(productId);
			 isFavoriteBean.setUserId(4085);
			 
			 isFavoriteCall.setData(isFavoriteBean);
			 isFavoriteCall.callService();
			 
			 int status = isFavoriteCall.getStatus();
			 
			 Logger.comment("getProductInfoCall send:" + isFavoriteCall.getEntityString());
			 Logger.comment("getProductInfoCall response:" + isFavoriteCall.getReturnData());
			 
			 Logger.verifyEquals(200, status, "判断接口status是否为200");
			 Logger.verifyNotNull(isFavoriteCall.getResult(), "验证result是否为空");
			 
		 } catch (Exception e) {
			 Logger.fail(e);
		 }
	 }
}
